// 该案例是一个工具栏的应用案例，其建立了一个工具栏，当单击工具栏中的各个按钮时
// 会在终端中输出对应的字符串。在工具栏单击事件的灰调函数ButtonEvent中调用了g_print函数，
// 用于输出当前被单击的工具按钮对应的提示字符串
#include <gtk/gtk.h>

void ButtonEvent(GtkWidget *widget,gpointer *data);

int main(int argc,char *argv[]){
	GtkWidget *window,*box,*toolbar,*image;	// 定义window/box/toorbar/image

	gtk_init(&argc,&argv);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window),"工具栏应用");
	gtk_widget_set_usize(window,1000,400);
	gtk_signal_connect(GTK_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL);

	// 创建box和工具条
	box = gtk_vbox_new(FALSE,0);
	toolbar = gtk_toolbar_new();
	gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,TRUE,5);

	image = gtk_image_new_from_file("1.ico");
	gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),"office","office",NULL,image,(GtkSignalFunc)ButtonEvent,"office");

	// 创建工具条里面的按钮
	image = gtk_image_new_from_file("2.ico");
	gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),"bitcomet","bitcomet",NULL,image,(GtkSignalFunc)ButtonEvent,"bitcomet");

	image = gtk_image_new_from_file("3.ico");
	gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),"blender","blender",NULL,image,(GtkSignalFunc)ButtonEvent,"blender");

	image = gtk_image_new_from_file("4.ico");
	// 调用创建菜单项函数
	//MenuItemFile = CreateMenuItem(MenuBar,"Fiel");
	gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),"coeur","coeur",NULL,image,(GtkSignalFunc)ButtonEvent,"coeur");

	image = gtk_image_new_from_file("5.ico");
	gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),"PS","PS",NULL,image,(GtkSignalFunc)ButtonEvent,"Ps");

	gtk_container_add(GTK_CONTAINER(window),box);
	gtk_widget_show(toolbar);
	gtk_widget_show(box);
	gtk_widget_show(window);
	gtk_main();

	return 0;

}

void ButtonEvent(GtkWidget *widget, gpointer *data){
	g_print("%s\n",data);
}



